/*
 * 日志控制器
 */
package com.cj.controller;

import com.cj.pojo.AuditLog;
import com.cj.pojo.PageBean;
import com.cj.pojo.Result;
import com.cj.service.AuditLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.cj.pojo.dto.AuditLogQueryDTO;

@RestController
@RequestMapping("/api/audit/log")
public class AuditLogController {
    @Autowired
    private AuditLogService auditLogService;

    // 删除日志
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Long id) {
        auditLogService.delete(id);
        return Result.success();
    }

    // 查询日志列表
    @PostMapping
    public Result<PageBean<AuditLog>> list(@RequestBody AuditLogQueryDTO queryDTO) {
        PageBean<AuditLog> pb = auditLogService.list(
            queryDTO.getUserId(),
            queryDTO.getActionType(),
            queryDTO.getStartTime(),
            queryDTO.getEndTime(),
            queryDTO.getPageNum(),
            queryDTO.getPageSize()
        );
        return Result.success(pb);
    }
}
